package com.lsy.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lsy.entity.AccountAndArticleCnd;
import com.lsy.entity.AccountAndCommentCnd;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 项目名：springboot01
 * 包名：com.lsy.dao
 * 类名：AccountAndCommentCndMapper
 * 描述：
 * 作者：柳胜酉
 * 开始时间：2023/6/14
 * 完成时间：
 * 版本：1.0
 */
@Mapper
public interface AccountAndCommentCndMapper extends BaseMapper<AccountAndCommentCnd> {
    @Select("select `comment`.comment_id,`comment`.article_id,`comment`.user_id,`comment`.comment_content,`comment`.comment_time,`comment`.comment_likes,account.user_id,account.account,account.`password`,account.role" +
            " from `comment`,account" +
            " where `comment`.user_id = account.user_id and account.user_id = #{account.user_id};")
    List<AccountAndCommentCnd> selectAccountAndCommentCndByUserId(Integer user_id);

    @Select("select `comment`.comment_id,`comment`.article_id,`comment`.user_id,`comment`.comment_content,`comment`.comment_time,`comment`.comment_likes,account.user_id,account.account,account.`password`,account.role" +
            " from `comment`,account" +
            " where `comment`.user_id = account.user_id;")
    List<AccountAndCommentCnd> selectAccountAndCommentCnd();

    @Select("select `comment`.comment_id,`comment`.article_id,`comment`.user_id,`comment`.comment_content,`comment`.comment_time,`comment`.comment_likes,account.user_id,account.account,account.`password`,account.role" +
            " from `comment`,account" +
            " where `comment`.user_id = account.user_id and `comment`.article_id = #{article_id};")
    List<AccountAndCommentCnd> selectAccountAndCommentCndByArticleId(Integer article_id);
}
